﻿#ifndef FMESSAGEBOX_H
#define FMESSAGEBOX_H

#include "../Base/FDialog.h"
#include <QMessageBox>
#include <QList>

namespace Ui {
class FMessageBox;
}

class FMessageBox : public FDialog
{
    Q_OBJECT

public:
    /// Copy from QMessageBox ----------------------------------------
    enum StandardButton {
        // keep this in sync with QDialogButtonBox::StandardButton and QPlatformDialogHelper::StandardButton
        NoButton           = 0x00000000,
        Ok                 = 0x00000400,
        Save               = 0x00000800,
        SaveAll            = 0x00001000,
        Open               = 0x00002000,
        Yes                = 0x00004000,
        YesToAll           = 0x00008000,
        No                 = 0x00010000,
        NoToAll            = 0x00020000,
        Abort              = 0x00040000,
        Retry              = 0x00080000,
        Ignore             = 0x00100000,
        Close              = 0x00200000,
        Cancel             = 0x00400000,
        Discard            = 0x00800000,
        Help               = 0x01000000,
        Apply              = 0x02000000,
        Reset              = 0x04000000,
        RestoreDefaults    = 0x08000000,

        FirstButton        = Ok,                // internal
        LastButton         = RestoreDefaults,   // internal

        YesAll             = YesToAll,          // obsolete
        NoAll              = NoToAll,           // obsolete

        Default            = 0x00000100,        // obsolete
        Escape             = 0x00000200,        // obsolete
        FlagMask           = 0x00000300,        // obsolete
        ButtonMask         = ~FlagMask          // obsolete
    };
    typedef StandardButton Button;  // obsolete

    Q_DECLARE_FLAGS(StandardButtons, StandardButton)
    Q_FLAG(StandardButtons)
    /// --------------------------------------------------------------


    explicit FMessageBox(QWidget* parent, const QString &title, const QString &text, const QIcon& icon,
                         StandardButton button1 = NoButton, StandardButton button2 = NoButton, StandardButton button3 = NoButton);

    ~FMessageBox();

    void setText(const QString& text);
    void setIcon(const QIcon& icon);

    StandardButton standardButton() const;

    static StandardButton information(QWidget* parent, const QString &title, const QString &text);
    static StandardButton    question(QWidget* parent, const QString &title, const QString &text);
    static StandardButton     warning(QWidget* parent, const QString &title, const QString &text);
    static StandardButton    critical(QWidget* parent, const QString &title, const QString &text);

private slots:
    void on_btn1_clicked();

    void on_btn2_clicked();

    void on_btn3_clicked();

private:
    Ui::FMessageBox *ui;
    StandardButton m_sb = NoButton;
    QList<StandardButton> m_btns;
};

#endif // FMESSAGEBOX_H
